/* boardview.h - this file is part of PixelMerge
 *
 * Copyright (C) 2010 Pascal Giard
 *
 * Author: Pascal Giard <evilynux@gmail.com>
 *
 * This file is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 *
 * This file is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; see the file COPYING.  If not, write to
 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 *
 * Game view.
 */

#ifndef BOARDVIEW_H
#define BOARDVIEW_H

#include <vector>

#include "libwiigui/gui.h"
#include "menu.h"
#include "pixelmerge.h"
#include "boardmodel.h"

class BoardView : public GuiWindow {
 public:
  BoardView(u8 gameDifficulty,
            BoardSettings boardSettings,
            UserSettings * userSettings);
  ~BoardView();
  int Run();
 private:
  BoardModel * model;
  GuiTrigger * trigA;
  GuiTrigger * trigHome;
  GuiImageData * btnOutline;
  GuiImageData * btnOutlineOver;
  GuiSound * btnSoundOver;
  GuiTrigger * trigPink;
  GuiTrigger * trigDarkBlue;
  GuiTrigger * trigYellow;
  GuiTrigger * trigRed;
  GuiTrigger * trigLightBlue;
  GuiTrigger * trigGreen;
  GuiText * newGameBtnTxt;
  GuiImage * newGameBtnImg;
  GuiImage * newGameBtnImgOver;
  GuiButton * newGameBtn;
  GuiText * exitBtnTxt;
  GuiImage * exitBtnImg;
  GuiImage * exitBtnImgOver;
  GuiButton * exitBtn;
  GuiImage * pixelImg[NBR_PIXELS];
  GuiButton * pixelBtn[NBR_PIXELS];
  GuiImageData * pixelBtnImgData[NBR_PIXELS];
  GuiImage * pixelBtnImg[NBR_PIXELS];
  GXColor pixelColor[NBR_PIXELS];
  std::vector <GuiImage *> boardImg;
  GuiText * stepTxt;
  char stepChars[15];
  GuiText * perfTxt;
  char perfChars[20];
  u8 pixelSize;
  u8 nbrSteps;
  bool gameComplete;
  u8 gameDiff;
  BoardSettings settings;
  UserSettings * user;
  
  void InitGameUI();
  void InitGameButtons();
  void NewGame();
  void UpdateBoard(u8 color);
  void CheckCompletion();
};

#endif /* BOARDVIEW_H */
